package com.changcheng.project.appupgradelog.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.changcheng.framework.aspectj.lang.annotation.Log;
import com.changcheng.framework.aspectj.lang.enums.BusinessType;
import com.changcheng.project.appupgradelog.domain.AAppUpgradelogs;
import com.changcheng.project.appupgradelog.service.IAAppUpgradelogsService;
import com.changcheng.framework.web.controller.BaseController;
import com.changcheng.framework.web.domain.AjaxResult;
import com.changcheng.common.utils.poi.ExcelUtil;
import com.changcheng.framework.web.page.TableDataInfo;

/**
 * OBU升级记录Controller
 * 
 * @author dazhi
 * @date 2020-10-31
 */
@Controller
@RequestMapping("/appupgradelog/appupgradelog")
public class AAppUpgradelogsController extends BaseController
{
    private String prefix = "appupgradelog/appupgradelog";

    @Autowired
    private IAAppUpgradelogsService aAppUpgradelogsService;

    @RequiresPermissions("appupgradelog:appupgradelog:view")
    @GetMapping()
    public String appupgradelog()
    {
        return prefix + "/appupgradelog";
    }

    /**
     * 查询OBU升级记录列表
     */
    @RequiresPermissions("appupgradelog:appupgradelog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AAppUpgradelogs aAppUpgradelogs)
    {
        startPage();
        List<AAppUpgradelogs> list = aAppUpgradelogsService.selectAAppUpgradelogsList(aAppUpgradelogs);
        return getDataTable(list);
    }

    /**
     * 导出OBU升级记录列表
     */
    @RequiresPermissions("appupgradelog:appupgradelog:export")
    @Log(title = "OBU升级记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AAppUpgradelogs aAppUpgradelogs)
    {
        List<AAppUpgradelogs> list = aAppUpgradelogsService.selectAAppUpgradelogsList(aAppUpgradelogs);
        ExcelUtil<AAppUpgradelogs> util = new ExcelUtil<AAppUpgradelogs>(AAppUpgradelogs.class);
        return util.exportExcel(list, "appupgradelog");
    }

    /**
     * 新增OBU升级记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存OBU升级记录
     */
    @RequiresPermissions("appupgradelog:appupgradelog:add")
    @Log(title = "OBU升级记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AAppUpgradelogs aAppUpgradelogs)
    {
        return toAjax(aAppUpgradelogsService.insertAAppUpgradelogs(aAppUpgradelogs));
    }

    /**
     * 修改OBU升级记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AAppUpgradelogs aAppUpgradelogs = aAppUpgradelogsService.selectAAppUpgradelogsById(id);
        mmap.put("aAppUpgradelogs", aAppUpgradelogs);
        return prefix + "/edit";
    }

    /**
     * 修改保存OBU升级记录
     */
    @RequiresPermissions("appupgradelog:appupgradelog:edit")
    @Log(title = "OBU升级记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AAppUpgradelogs aAppUpgradelogs)
    {
        return toAjax(aAppUpgradelogsService.updateAAppUpgradelogs(aAppUpgradelogs));
    }

    /**
     * 删除OBU升级记录
     */
    @RequiresPermissions("appupgradelog:appupgradelog:remove")
    @Log(title = "OBU升级记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(aAppUpgradelogsService.deleteAAppUpgradelogsByIds(ids));
    }
}
